import { homeCategoryHead } from '@/api/category'
const state = {
  list: []
}

const mutations = {
  setList (state, step) {
    state.list = step
  },
  open (state, step) {
    state.list.map(item => {
      if (item.id === step) {
        item.show = true
        return item
      }
      return item
    })
  },
  hide (state, step) {
    state.list.map(item => {
      if (item.id === step) {
        item.show = false
        return item
      }
      return item
    })
  }
}
const actions = {
  async getList ({ commit }) {
    const res = await homeCategoryHead()
    res.result.forEach(item => {
      item.show = false
    })
    commit('setList', res.result)
    console.log(res)
  }
}
const getters = {}
export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
